package chpt08;

import java.io.PipedOutputStream;

public class Sender implements Runnable{
    PipedOutputStream out;
	public Sender( PipedOutputStream out) {
        this.out = out;
    }
    public void run() {
    	String[] msgs = new String[] {"Hello!","How are you!"
,"Bye!"};
    	byte[] buf = new byte[256];	
        try {
            for(String msg:msgs) {
            	buf = msg.getBytes();
				out.write(buf);
                out.flush();
                Thread.sleep(2000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
